package com.xiaotu.sys.controller;


import com.xiaotu.result.R;
import com.xiaotu.sys.pojo.entity.Role;
import com.xiaotu.sys.service.RoleService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *  新增
 *  列表
 *  赋权
 *  id/name
 * @author xiaotu
 * @since 2022-01-19
 */
@CrossOrigin
@Api("用户管理")
@RestController
@RequestMapping("/sys/role")
public class RoleController {
    @Autowired
    private RoleService roleService;
    @GetMapping
    public R getList(){
        List<Role> list = roleService.list();
        return R.ok().data("list",list);
    }

    @PostMapping
    public R insertRole(@RequestBody Role role){
        boolean save = roleService.save(role);
        return R.ok().message("新增角色成功");
    }

}
